﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileStorage.Caching
{
    /// <summary>
    /// Describes the contract a class should implement to act like a container of cached items.
    /// Caching of items from a NFileStorage could be handy in situations where the
    /// NFileStorage contains limited items that are to be considered 'static',
    /// or when the NFileStorage is access in high frequences for specific items in a
    /// relatively small while. 
    /// Keep in mind that your HD also performs caching, so using this caching concept 
    /// might be 'overkill' (it really depends on the situation).
    /// </summary>
    public interface ICacheContainer
    {
        /// <summary>
        /// Validates the cached item (if present). This function allows a specific implementation to remove an item from cache
        /// when its expired, or update for example usage (frequency) tables for the item
        /// </summary>
        void Validate(string fileStorageName, Guid dataIdentifier, FileStorageCacherFacade.CacheMethodInvocationsEnum cacheMethodInvocationsEnum);

        /// <summary>
        /// Determines whether the item is available in the cache
        /// </summary>
        bool Exists(string fileStorageName, Guid dataIdentifier, FileStorageCacherFacade.CacheMethodInvocationsEnum cacheMethodInvocationsEnum);

        /// <summary>
        /// Retrieves an item from the cache
        /// </summary>
        object Get(string fileStorageName, Guid dataIdentifier, FileStorageCacherFacade.CacheMethodInvocationsEnum cacheMethodInvocationsEnum);

        /// <summary>
        /// Stores an item in the cache
        /// </summary>
        void Store(string fileStorageName, Guid dataIdentifier, FileStorageCacherFacade.CacheMethodInvocationsEnum cacheMethodInvocationsEnum, object objectToStore);

        /// <summary>
        /// Invalidates all items in the cache
        /// </summary>
        void InvalidateAll();

        /// <summary>
        /// Counts the number of cached items
        /// </summary>
        /// <returns></returns>
        int Count();
    }
}
